package com.group3.controller.adminController;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.group3.controller.Validated.Update;
import com.group3.pojo.receive.StudentReceive;
import com.group3.service.AStudentService;
import com.group3.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * AStudentController
 *
 * @author HY
 * 2021/06/04 8:41
 **/


//管理学生的接口
@Api(tags = "管理员接口")
@RestController
@RequestMapping("/admin/student")
public class AStudentController {

    @Resource
    private AStudentService aStudentService;

    //    管理员修改学生信息
    @PutMapping(value = "/putStudent"  )
    @ApiOperation(value = "修改学生信息"  )
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "studentId", value = "修改后学生的学号",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "BeforeStudentId", value = "修改前学生的学号", required = true,
//                    dataType = "String"),
//            @ApiImplicitParam(name = "studentName", value = "学生姓名",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "sex", value = "学生性别",
//                    dataType = "int"),
//            @ApiImplicitParam(name = "cardId", value = "学生身份证",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "email", value = "学生邮箱",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "tel", value = "学生电话",
//                    dataType = "String"),
//            @ApiImplicitParam(name = "type", value = "项目角色",
//                    dataType = "String"),
//    })
    @ApiOperationSupport(ignoreParameters = {"pageNumber","pageSize"})
    public Result updateStudent(
//            @NotEmpty @PathVariable("studentId") String studentId,
            @Validated({Update.class}) @RequestBody StudentReceive studentReceive) {

        return aStudentService.updateStudentInfo(studentReceive);
    }

    //    管理员删除学生信息
    @DeleteMapping(value = "/deleteStudent",
            consumes = "application/json")
    @ApiOperation(value = "删除学生信息"  )
    @ApiImplicitParam(name = "studentIds", value = "学生学号集合", required = true,
            dataType = "List<String>")
    public Result deleteStudent(
            @Validated({Update.class}) @RequestBody List<String> studentIds) {

        //批量删除学生:将学生从班级中移出
        return aStudentService.deleteStudent(studentIds);
    }


}
